package com.gaohe.web.controller.scp;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.scp.domain.CsNoticeContent;
import com.gaohe.scp.service.ICsNoticeContentService;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.common.core.page.TableDataInfo;

/**
 * 通知内容Controller
 *
 * @author liuxiangyu
 * @date 2025-03-25
 */
@RestController
@RequestMapping("/scp/content")
public class CsNoticeContentController extends BaseController
{
    @Autowired
    private ICsNoticeContentService csNoticeContentService;

    /**
     * 查询通知内容列表
     */
//    @PreAuthorize("@ss.hasPermi('scp:content:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsNoticeContent csNoticeContent)
    {
        startPage();
        List<CsNoticeContent> list = csNoticeContentService.selectCsNoticeContentList(csNoticeContent);
        return getDataTable(list);
    }

    /**
     * 导出通知内容列表
     */
//    @PreAuthorize("@ss.hasPermi('scp:content:export')")
    @Log(title = "通知内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsNoticeContent csNoticeContent)
    {
        List<CsNoticeContent> list = csNoticeContentService.selectCsNoticeContentList(csNoticeContent);
        ExcelUtil<CsNoticeContent> util = new ExcelUtil<CsNoticeContent>(CsNoticeContent.class);
        util.exportExcel(response, list, "通知内容数据");
    }

    /**
     * 获取通知内容详细信息
     */
//    @PreAuthorize("@ss.hasPermi('scp:content:query')")
    @GetMapping(value = "/{contentId}")
    public AjaxResult getInfo(@PathVariable("contentId") Long contentId)
    {
        return success(csNoticeContentService.selectCsNoticeContentByContentId(contentId));
    }

    /**
     * 新增通知内容
     */
//    @PreAuthorize("@ss.hasPermi('scp:content:add')")
    @Log(title = "通知内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsNoticeContent csNoticeContent)
    {
        return toAjax(csNoticeContentService.insertCsNoticeContent(csNoticeContent));
    }

    /**
     * 修改通知内容
     */
//    @PreAuthorize("@ss.hasPermi('scp:content:edit')")
    @Log(title = "通知内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsNoticeContent csNoticeContent)
    {
        return toAjax(csNoticeContentService.updateCsNoticeContent(csNoticeContent));
    }

    /**
     * 删除通知内容
     */
//    @PreAuthorize("@ss.hasPermi('scp:content:remove')")
    @Log(title = "通知内容", businessType = BusinessType.DELETE)
    @DeleteMapping("/{contentIds}")
    public AjaxResult remove(@PathVariable Long[] contentIds)
    {
        return toAjax(csNoticeContentService.deleteCsNoticeContentByContentIds(contentIds));
    }
    @GetMapping("/messageDetail/{id}")
    public AjaxResult selectMessageDetail(@PathVariable Long id){
        System.out.println(666666);
        System.out.println(id);
        return success(csNoticeContentService.selectCsNoticeContent(id));
    }
}
